package com.fomky.queried.service.query.controller;

import com.fomky.queried.common.connect.RowDataList;
import com.fomky.queried.common.entity.QueryRequest;
import com.fomky.queried.common.entity.QueryResponse;
import com.fomky.queried.service.query.service.QueryService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;


@RestController
@RequestMapping("/v1/api/query")
public class QueryController {

    @Resource
    QueryService queryService;


    @PostMapping("/run")
    public QueryResponse run(@RequestBody QueryRequest request) {
        RowDataList rowDataList = queryService.queryRequest(request);
        return QueryResponse.builder()
                .list(rowDataList)
                .request(request).build();
    }

}
